package com.fastfood.controller;

import com.fastfood.model.blo.AccountBLO;
import com.fastfood.model.dto.Account;
import com.opensymphony.xwork2.ActionSupport;

public class AuthenticationAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private AccountBLO accountBLO;
	
	private String username;
	private String password;
	
	private boolean success;
	
	public AuthenticationAction() {
		accountBLO = new AccountBLO();
	}
	
	public String login() {
		Account account = accountBLO.getAccountByUsernameAndPassword(username, password);
		if (account == null) {
			success = false;
			return ERROR;
		} else {
			success = true;
			return SUCCESS;
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}	
}
